package cn.jason.org.service.impl;

import cn.jason.basic.service.impl.BaseServiceImpl;
import cn.jason.basic.util.PageList;
import cn.jason.org.domain.Dictionary;
import cn.jason.org.mapper.DictionaryMapper;
import cn.jason.org.query.DictionaryQuery;
import cn.jason.org.service.IDictionaryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author xxx
 */
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class DictionaryServiceImpl extends BaseServiceImpl<Dictionary> implements IDictionaryService {

    private final DictionaryMapper dictionaryMapper;

    public DictionaryServiceImpl(DictionaryMapper dictionaryMapper) {
        this.dictionaryMapper = dictionaryMapper;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void save(Dictionary dictionary) {
        dictionaryMapper.save(dictionary);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(Dictionary dictionary) {
        dictionaryMapper.update(dictionary);
    }

    @Override
    public PageList<Dictionary> queryPage(DictionaryQuery query) {
        Long total = dictionaryMapper.queryCount(query);
        List<Dictionary> rows = dictionaryMapper.queryData(query);
        return new PageList<>(total, rows);
    }


}
